import request from '/@/utils/request';

/**
 * 用户API
 *
 * @method list 获取列表
 * @method info 根据id获取信息
 * @method add 添加
 * @method edit 修改
 * @method del 删除
 * @method validateUsername 校验用户名是否存在
 * @method validatePhone 校验手机号是否存在
 */
export function useUserApi() {
	return {
		list: (params?: object) => {
			return request({
				url: '/sys/user/list',
				method: 'get',
				params,
			});
		},
		info: (id?: String) => {
			return request({
				url: '/sys/user/info',
				method: 'get',
				params: { id },
			});
		},
		add: (data?: object) => {
			return request({
				url: '/sys/user/add',
				method: 'post',
				data,
			});
		},
		edit: (data?: object) => {
			return request({
				url: '/sys/user/edit',
				method: 'put',
				data,
			});
		},
		del: (ids?: object) => {
			return request({
				url: '/sys/user/del',
				method: 'delete',
				data: ids,
			});
		},
		validateUsername: (username?: string) => {
			return request({
				url: '/sys/user/validate/username',
				method: 'get',
				params: { username },
			});
		},
		validatePhone: (phone?: string) => {
			return request({
				url: '/sys/user/validate/phone',
				method: 'get',
				params: { phone },
			});
		},
	};
}
